﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AcademiaInteligenteWeb
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {  
            WsAcademiaInteligente.Funcionario funcionario = new WsAcademiaInteligente.WsAcademiaInteligenteSoapClient().SelecionarFuncionarioPorLoginSenha(txtLogin.Text, txtSenha.Text);
            if (funcionario != null)
            {
                Session[Util.SESSION_USER_ID] = funcionario.Id;
                Session[Util.SESSION_ACADEMIA_ID] = funcionario.Id_academia;
                Response.Redirect("Main.aspx");
            }
            else
            {
                lblMsg.Text = Util.LOGIN_INVALIDO;
            }
        }
    }
}